Skip to content

Conversation

@uns4inted
Copy link

If you try to deploy the project using Vercel - you will be getting errors on first load when fetching data of prompts. I've been seeing this errors on Feed and Profile components on first load of the page (When serverless functions are on cold boot) or after some delay when the web site was inactive (about after 15-30 min).
The server error message is MissingSchemaError: Schema hasn't been registered for model "User". Use mongoose.model(name, schema).
To fix the problem you need to add Imports of the User model where you are using .populate("creator") method.

What is interesting about this issue - is that you're not getting this errors in local development runs or even after site was active after some reloads.

The material I was using to fix the problem: https://dev.to/janetthedev/using-mongooses-populate-in-nextjs-4jof

@vercel
Copy link

vercel bot commented May 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
project-promptopia-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2023 8:05pm

@vercel
Copy link

vercel bot commented May 25, 2023

@uns4inted is attempting to deploy a commit to the JS Mastery PRO Team on Vercel.

A member of the Team first needs to authorize it.

Minor fix: typo in API route file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant